//
//  ViewController.m
//  TestIAP
//
//  Created by 朱志佳 on 2020/5/29.
//  Copyright © 2020 朱志佳. All rights reserved.
//

#import "ViewController.h"
#import "YYKit.h"
#import "IAPManager.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //[self testJSON];
    //[self testIAP];
}

- (void)testJSON {
    NSDictionary *dict = @{@"1":@"2"};
    NSString *json = dict.modelToJSONString;
    NSLog(@"json:%@", json);

    dict = json.jsonValueDecoded;
    NSLog(@"dict:%@", dict);
    
}

/*
 应用组、账号、服务
 参照钥匙串密码存储
 accessGroup
 account
 service
 server
 */

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
    NSString *productIdentifier = @"com.lestory.jihua.oneDay";
    productIdentifier = @"com.lestory.jihua.oneMonthVIP";
    productIdentifier = @"com.lestory.jihua.1_month_vip";

    [IAPManager.shared requestProductWithId:productIdentifier tradeResultBlock:^(BOOL success, NSInteger code, NSString *error) {
        
        if (!success) {
            NSLog(@"errorCode:%ld##errorStr:%@",code,error);
            return;
        }
       
        NSLog(@"本次交易成功完成");
        
    }];;
    
}


@end
